$(function () {
    //渲染表格
    var columns = cacheDataList.columnsInit();
    var table = cacheDataList.gridInit(columns);
   // var datas = cacheDataList.dataInit();
   // $("#cacheDataTable").bootstrapTable("append",datas);
})
;(function(undefined) {
    "use strict"
    var _global;

    function result(args,fn){
        var argsArr = Array.prototype.slice.call(args);
        if(argsArr.length > 0){
            return argsArr.reduce(fn);
        } else {
            return 0;
        }
    }
    var cacheDataList = {
        columnsInit:function(){
            return  [{
                field: 'od',
                title: '序号',
                width: '2%',
                align: 'center',
                formatter: function (value, row, index) {
                    var e = index + 1;
                    return e;
                }
            }, {
                field: 'pk',
                title: '编号',
                sortable: true
            }, {
                field: 'pwd',
                title: '密码'
            }]
        },
        gridInit:function(columns){
            return $("#cacheDataTable").bootstrapTable({

                columns: columns,
                classes: 'table table-hover qxttable',
                method: 'post',
                sortable: true,
                pagination: false,
                url: $$.restServerUrl + '/bootstrap/basegrid/IotDeviceBusiness/tableDataList',
                cache: false,
                striped: true,
                onlyInfoPagination: true,
                pageList: [10, 20, 50, 100],
                showColumns: false,
                showRefresh: false,
                search: false,
                clickToSelect: true,
                dataField: "rows",
                pageNumber: 1,
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                singleSelect: false,
                queryParamsType: "page",
                sidePagination: "server",
                undefinedText: '-',
                contentType: "application/x-www-form-urlencoded",
                pageSize: 10,
                idField: 'pk',
                toolbarAlign: 'right',




            })

        },
        dataInit:function(){
            return  [{
                od: 1,
                pk: 'DLC0001',
                pwd: 'DLC0001'
            }, {
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 3,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 4,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 5,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 6,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 7,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 8,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 9,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 10,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 11,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 12,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            },{
                od: 13,
                pk: 'DLC0001',
                pwd: 'DLC0001',
            }]
        }
    }

    // 将插件对象暴露给全局对象
    _global = (function(){ return this || (0, eval)('this'); }());
    if (typeof module !== "undefined" && module.exports) {
        module.exports = cacheDataList;
    } else if (typeof define === "function" && define.amd) {
        define(function(){return cacheDataList;});
    } else {
        !('plugin' in _global) && (_global.cacheDataList = cacheDataList);
    }
}());